

import UtilFuncs from '../canvas/common/tools/utilfuncs.js'
var utilfuncs = UtilFuncs.UtilFuncs;
import GlobalConst from '../canvas/common/globalConst.js'
var global = GlobalConst.GlobalConst;

import polylinePkg from '../canvas/common/struct/basestruct/polyline.js'
import rectanglePkg from '../canvas/common/struct/basestruct/rectangle.js'
import devgraphinfoPkg from '../canvas/common/struct/basestruct/devgraphinfo.js'
import CirclePkg from '../canvas/common/struct/basestruct/circle.js'
import PolygonPkg from '../canvas/common/struct/basestruct/polygon.js'
import TerminalPkg from '../canvas/common/struct/basestruct/terminal.js'
import textinfo from '../canvas/common/struct/basestruct/textinfo.js';
import imageInfo from '../canvas/common/struct/basestruct/ImageInfo.js'
import arc from '../canvas/common/struct/basestruct/arc.js'
import regularpolygon from '../canvas/common/struct/basestruct/regularpolygon.js';
import multistar from '../canvas/common/struct/basestruct/multistar.js';
import cube from '../canvas/common/struct/basestruct/cube.js';
import cylinder from '../canvas/common/struct/basestruct/cylinder.js';
import specialrect from '../canvas/common/struct/basestruct/specialrect.js';
import ellipseacr from '../canvas/common/struct/basestruct/ellipseacr.js';
import ellipse from '../canvas/common/struct/basestruct/ellipse.js';
import pathinfo from '../canvas/common/struct/basestruct/pathinfo.js';

var GraphDataFactory = {


}

GraphDataFactory.create = function (fullType) {
    var info = null;
    var zhutype = fullType >> 16;
    var strID = zhutype.toString(16);
    if (zhutype == global.AuxLine) 
    {
        console.log(strID);
    }

    let subType = fullType>>8;
    if (subType == global.RegularPolygon){
        info = new regularpolygon.RegulaPolygonUnit();
    }
    else if (subType == global.MultiStarPolygon){
        info = new multistar.MultiStarUnit();
    }
    else if (zhutype == global.BaseUnitPolyline
        || zhutype == global.ConnectLine
        || zhutype == global.CommBusLine
        || zhutype == global.AuxLine
        || zhutype == global.SpLine) {
        info = new polylinePkg.Polyline();
    }
    else if (zhutype == global.BaseUnitRectangle) {
        info = new rectanglePkg.Rectangle();
    }
    else if (utilfuncs.isMoldGraph32(fullType)) {
        info = new devgraphinfoPkg.DevGraphInfo();
    }
    else if (zhutype == global.BaseUnitCircle) {
        info = new CirclePkg.Circle();
    }
    else if (zhutype == global.BaseUnitPolygon
        ||zhutype == global.BezierCurve
        ||zhutype == global.QuadraticCurve)
    {
        info = new PolygonPkg.Polygon();
    }
    else if (zhutype == global.TerminalType)
    {
        info = new TerminalPkg.Terminal();
    }

    else if (zhutype == global.BaseUnitText
             || zhutype == global.BaseUnitYCText)
    {
        info = new textinfo.TextInfo();
    }
    else if (zhutype == global.BaseUnitImage)
    {
        info = new imageInfo.ImageInfo();
    }
    else if (zhutype == global.BaseUnitArc)
    {
        info = new arc.Arc();
    }
    else if (zhutype == global.CubeType){
        info = new cube.Cube();
    }
    else if (zhutype == global.CylinderType){
        info = new cylinder.Cylinder();
    }
    else if (zhutype == global.SpecialRectType){
        info = new specialrect.SpecialRect();
    }
    else if (zhutype == global.BaseUnitEllipseArc){
        info = new ellipseacr.EllipseArc();
    }
    else if (zhutype == global.Hatch){
        info = new hatchinfo.HatchInfo();
    }
    else if (zhutype == global.BaseUnitEllipse) {
        info = new ellipse.Ellipse();
    }
    else if (zhutype == global.PathType){
        info = new pathinfo.PathInfo();
    }

    if (!info && (zhutype>>8 == 0x02)){
        info = new devgraphinfoPkg.DevGraphInfo();
    }

    if (info) {
        info.type = parseInt(fullType);
    }

    return info;
}

export default { GraphDataFactory }